<?php
namespace App\Http\Controllers\Admin\Qudao;

use App\Service\Admin\Qudao\CommonService;
use Illuminate\Http\Request;

class CommonController extends BaseController
{
    //配置

    public function __construct()
    {
        $this->db = new CommonService();
    }

    //列表
    public function getList(Request $request)
    {
        $res = $this->db->getList();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    //修改
    public function modify(Request $request)
    {
        $id = $request->post('id', 0);
        $val = $request->post('val', '');
        $res = $this->db->modify($id, $val);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }
}